package com.tk.itext7demo.utils.excel;

import com.itextpdf.kernel.geom.PageSize;



import java.io.*;
import java.nio.file.Files;
import java.util.Collections;
/**
 * @program: checkmall
 * @description:
 * @author: tjw
 * @create: 2022-12-23 16:15
 **/
public class Demo {
    public static void main(String[] args) {
        //excel文件的地址
        File excelFile = new File("C:\\Study\\java/itext7-demo/testDir/template.xlsx");
        //pdf文件的地址
        File pdfFile = new File("C:\\Study\\java/itext7-demo/testDir/template.pdf");

        try (InputStream in = Files.newInputStream(excelFile.toPath()); OutputStream out = Files.newOutputStream(pdfFile.toPath())) {
            Excel2Pdf excel2Pdf = new Excel2Pdf(Collections.singletonList(
                    new ExcelObject(in)
            ), out);
            excel2Pdf.convert(PageSize.A4.rotate());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
